package com.woniuxy.microorderserver.controller;

import com.github.pagehelper.PageInfo;
import com.woniuxy.microcommonserver.bean.order_caize.OrderInfo;
import com.woniuxy.microcommonserver.bean.order_caize.ShipperInfo;
import com.woniuxy.microcommonserver.pageHelper.PageRequest;
import com.woniuxy.microcommonserver.pageHelper.TableResult;
import com.woniuxy.microcommonserver.res.ResultMsg;
import com.woniuxy.microorderserver.service.IOrderService;
import com.woniuxy.microorderserver.service.IShipperService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
@RestController
@RequestMapping("/shipper")
public class ShipperMapperController {
    @Resource
    private IShipperService shipperServiceImpl;

    /**
     * 分页查询所有发货人
     */
    @RequestMapping(value = "/all",produces = {"application/json;charset=utf-8"})
    public TableResult<ShipperInfo> findShipperAll(PageRequest request){
        PageInfo<ShipperInfo> pageInfo = shipperServiceImpl.findShipperAll(request);

        return new TableResult(pageInfo.getTotal(),pageInfo.getList());
    }
    /**
     * 删除发货人信息
     */
    @PutMapping(value = "/del/{ids}",produces = {"application/json;charset=utf-8"})
    public void delShipper(@PathVariable("ids") Long ids[]){

        for (Long id:ids) {
            shipperServiceImpl.delShipper(id);
        }


    }
    @RequestMapping(value = "/add",produces = {"application/json;charset=utf-8"})
    void addShipper(ShipperInfo shipperInfo){
        shipperServiceImpl.addShipper( shipperInfo);
    }
}
